package io.filecopy;

import java.io.File;
import java.io.IOException;

public class CreateDirTask implements FileSystemTask {

  private File destDir;

  public CreateDirTask(File destDir) {
    this.destDir = destDir;
  }

  @Override
  public void execute(final ProgressLogger progress) throws IOException {
    boolean success = destDir.mkdir();
    if (success){
      progress.directoryCreated();
    } else {
      progress.directoryCreationFailed();
      throw new IOException("Directory can not be created.");
    }
  }

  @Override
  public String toString() {
    return "create directory \"" + destDir.getAbsolutePath() + "\"";
  }
}